<template>
    <div class="app-container order">
        <div v-if="open == !true">
            <el-form ref="queryForm" :inline="true" label-width="105px" style="margin:0 ;padding:0 50px 0 0px;">
                <el-form-item label="下单时间" prop="orderTime">
                    <el-date-picker format="yyyy-MM-dd" value-format="yyyy-MM-dd" clearable size="small" style="width: 200px" v-model="queryParams.orderTime" type="date" placeholder="选择下单时间"></el-date-picker>
                </el-form-item>
                <el-form-item label="收件人手机号" prop="contactWay">
                    <el-input v-model="queryParams.contactWay" placeholder="请输入收件人手机号" clearable size="small" @keyup.enter.native="handleQuery" />
                </el-form-item>
                <el-form-item label="企业名称" prop="companyName" v-show="isshow">
                    <el-input v-model="queryParams.companyName" placeholder="请输入企业名称" clearable size="small" @keyup.enter.native="handleQuery" />
                </el-form-item>
                <el-form-item label="平台名称" prop="plat">
                    <el-input v-model="queryParams.plat" placeholder="请输入平台名称" clearable size="small" @keyup.enter.native="handleQuery" />
                </el-form-item>
                <el-form-item label="店铺名称" prop="shop">
                    <el-input v-model="queryParams.shop" placeholder="请输入店铺名称" clearable size="small" @keyup.enter.native="handleQuery" />
                </el-form-item>
                <el-form-item label="主订单号" prop="orderId">
                    <el-input v-model="queryParams.orderId" placeholder="请输入订单ID" clearable size="small" @keyup.enter.native="handleQuery" />
                </el-form-item>

<!--                <el-form-item label="子订单号" prop="orderIda">-->
<!--                    <el-input v-model="queryParams.orderIda" placeholder="请输入订单ID" clearable size="small" @keyup.enter.native="handleQuery" />-->
<!--                </el-form-item>-->

                <!-- <el-form-item label="商品品牌" prop="brandId">
        <el-input
          v-model="queryParams.brandId"
          placeholder="请输入所属平台ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="商品分类" prop="categoryId">
        <el-input
          v-model="queryParams.categoryId"
          placeholder="请输入所属平台ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->

                <el-form-item label="商品品牌" prop="brandNo">
                    <el-select class="select" v-model="queryParams.brandNo" @change="handleQuery" allow-create filterable default-first-option placeholder="请选择品牌标签">
                        <el-option v-for="item in brandOptions" :key="item.brandNo" :label="item.brandName" :value="item.brandNo"> </el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="品类" prop="categoryNo">
                    <el-cascader v-model="queryParams.categoryNo" :options="options" :props="optionProps" :show-all-levels="false" @change="handleQuery" clearable></el-cascader>
                </el-form-item>

                <el-form-item label="SKU编号" prop="skuNo">
                    <el-input v-model="queryParams.skuNo" placeholder="请输入SKU编码" clearable size="small" @keyup.enter.native="handleQuery" />
                </el-form-item>
                <el-form-item label="SPU编号" prop="goodsNo">
                    <el-input v-model="queryParams.goodsNo" placeholder="请输入SPU编码" clearable size="small" @keyup.enter.native="handleQuery" />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                </el-form-item>
                <el-form-item>
                    <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                </el-form-item>
                <el-form-item>
                    <el-button type="warning" icon="el-icon-upload2" size="mini" v-hasPermi="['biz:order:export']" @click="update">下载模板</el-button>
                    <el-upload style="display:inline-block" ref="dealFile" :action="importAction" :headers="headers" :before-upload="fileBeforeUpload" :on-success="fieldBeforeUpload">
                        <el-button type="warning" icon="el-icon-upload2" size="mini" v-hasPermi="['biz:order:export']">导入</el-button>
                    </el-upload>
                    <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['biz:order:export']">导出</el-button>
                </el-form-item>
            </el-form>
            <el-radio-group v-model="radio" v-for="(item, index) in radioList" :key="index" @change="handleQueryttt">
                <el-radio-button :label="item" :key="index"></el-radio-button>
            </el-radio-group>
            <!-- 表格 -->
            <el-table @selection-change="handleSelectionChange" :data="orderList" style="width: 100%">
                <el-table-column type="selection" width="55" align="center"> </el-table-column>
                <el-table-column prop="date" label="商品信息" width="330">

                    <template slot-scope="scope">
                        <div v-for="(items, index) in scope.row.goodsDeail" :key="index">
                            <div v-if="items.info" class="tableCont">
                                <img :src="items.info.mainImgUrl" alt />
                                <div class="title" style>
                                    {{ items.info.goodsName }}
                                    [品牌] {{ items.info.brandName }}
                                    [规格]  {{ items.info.spec }} x
                                    {{ items.goods.goodsNum }}
                                </div>
                                <div class style="margin-left:5px" v-show="cisshow">
                                    <el-button class="elbutton" v-if="userId != 4" size="mini" type="text" @click="sopenkuang(2, scope.row.orderId, items.goods.goodsId,items.goods)">退货退款</el-button>
                                    <el-button class="elbutton" v-if="userId != 4" size="mini" type="text" @click="sopenkuang(3, scope.row.orderId, items.goods.goodsId,items.goods)">仅退款</el-button>
                                    <el-button class="elbutton" v-if="userId != 4" size="mini" type="text" @click="sopenkuang(1, scope.row.orderId, items.goods.goodsId,items.goods)">补偿</el-button>
                                </div>
                            </div>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column prop="orderId" label="主订单号" width="130"></el-table-column>
                <el-table-column prop="wuliuInfo.content" label="子订单号" width="130">
                    <template slot-scope="scope">
                        <div v-for="(items, index) in scope.row.wuliuInfo.content" :key="index">
                            <div class="title" style>
                                {{ items.subOrderSn }}
                            </div>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column prop="status" label="订单状态" width="100"></el-table-column>
                <el-table-column prop="payPrice" label="支付金额" width="100"></el-table-column>
                <el-table-column prop="goodsNum" label="订购数量"></el-table-column>
                <el-table-column prop="peopleInfo" label="收货人信息" width="200"></el-table-column>
                <el-table-column prop="orderTime" label="下单时间" width="100"></el-table-column>
                <el-table-column prop="stockTotalPrice" label="结算价格" width="100"></el-table-column>
                <el-table-column fit prop="shop" label="店铺" width="140"></el-table-column>
                <el-table-column label="操作" width="100" fixed="right">
                    <template slot-scope="scope">
                        <el-button style="margin-left: 10px;" size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">订单详情</el-button>
                        <el-button v-show="cisshow" size="mini" type="text" icon="el-icon-s-shop" @click="openkuang(1, scope.row.orderId,scope.row)">申请补偿</el-button>
                        <el-button v-show="cisshow" size="mini" type="text" icon="el-icon-s-finance" @click="openkuang(2, scope.row.orderId,scope.row)">退货退款</el-button>
                        <el-button v-show="cisshow" size="mini" type="text" icon="el-icon-s-help" @click="openkuang(3, scope.row.orderId,scope.row)">仅退款</el-button>
                    </template>
                </el-table-column>
            </el-table>

            <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

            <!-- 弹窗 -->
            <el-dialog title="申请补偿" :visible.sync="dialogVisible1" width="500px">
                <div class="sync">
                    <span>申请补偿金额</span>
                    <el-input class="input" v-model="ruleForm.money">请输入内容</el-input>
                </div>
                <div class="sync">
                    <span>申请补偿原因</span>
                    <el-input class="input" v-model="ruleForm.reason">请输入内容</el-input>
                </div>
                <div class="sync">
                    <span>备注</span>
                    <el-input class="input" v-model="ruleForm.remarks">请输入内容</el-input>
                </div>
                <div style="text-align:center;margin-top:20px">
                    <el-button type="primary" @click="saveBtn(0)">申请</el-button>
                    <el-button @click="cancel">取消</el-button>
                </div>
            </el-dialog>
            <el-dialog title="退货退款" :visible.sync="dialogVisible2" width="600px">
                <div class="sync">
                    <span>申请退货退款金额</span>
                    <el-input class="input" v-model="ruleForm.money">请输入内容</el-input>
                </div>
                <div class="sync">
                    <span>申请退货退款原因</span>
                    <el-input class="input" v-model="ruleForm.reason">请输入内容</el-input>
                </div>
                <div class="sync">
                    <span>备注</span>
                    <el-input class="input" v-model="ruleForm.remarks">请输入内容</el-input>
                </div>
                <div style="text-align:center;margin-top:20px">
                    <el-button type="primary" @click="saveBtn(2)">申请</el-button>
                    <el-button @click="cancel">取消</el-button>
                </div>
            </el-dialog>
            <el-dialog title="退款" :visible.sync="dialogVisible3" width="500px">
                <div class="sync">
                    <span>申请退款金额</span>
                    <el-input class="input" v-model="ruleForm.money">请输入内容</el-input>
                </div>
                <div class="sync">
                    <span>申请退款原因</span>
                    <el-input class="input" v-model="ruleForm.reason">请输入内容</el-input>
                </div>
                <div class="sync">
                    <span>备注</span>
                    <el-input class="input" v-model="ruleForm.remarks">请输入内容</el-input>
                </div>
                <div style="text-align:center;margin-top:20px">
                    <el-button type="primary" @click="saveBtn(1)">申请</el-button>
                    <el-button @click="cancel">取消</el-button>
                </div>
            </el-dialog>
        </div>
        <orderDetails v-if="open == true" @toRetreat="toRetreat" :datalist="form"></orderDetails>
        <preview class="preview" :lists="lists" :hiddens="hiddens" :dialogVisibless="dialogVisibless" :msg="msg" :datas="datas" @showbox="showbox" @showboxs="getList" />
    </div>
</template>

<script>
import { listOrder, getOrder, delOrder, addOrder, updateOrder, exportOrder, submitSinfo, importOrder, btnshouhou } from '@/api/biz/order';
import orderDetails from '@/components/orderDetails/index';
import preview from '@/components/preview/index';
import { getToken } from '@/utils/auth';

export default {
    name: 'Order',
    components: {
        orderDetails,
        preview
    },
    data() {
        return {
            baseimg: require('../../../assets/image/profile.jpg'),
            isshow: false,
            skuNoLists: [],

            cisshow: false,
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 总条数
            total: 0,
            // 订单表格数据
            orderList: [],
            // 弹出层标题
            title: '',
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                uid: undefined,
                companyName: undefined,
                number: undefined,
                type: undefined,
                status: undefined,
                platId: undefined,
                plat: undefined,
                shopId: undefined,
                shop: undefined,
                platOrderid: undefined,
                orderTime: undefined,
                payTime: undefined,
                payPrice: undefined,
                prePrice: undefined,
                extension: undefined,
                createdTime: undefined,
                shopId: this.$store.state.user.shopid,
                goodsNo: undefined,
                skuNo: undefined,
                brandNo: undefined,
                catogeryNo: undefined,
                orderIda: '',
                orderId: '',
                fileList: ''
            },
            lists: [],
            // 表单参数
            form: {},
            // 表单校验
            rules: {
                uid: [
                    {
                        required: true,
                        message: '用户id不能为空',
                        trigger: 'blur'
                    }
                ],
                number: [
                    {
                        required: true,
                        message: '订单ID不能为空',
                        trigger: 'blur'
                    }
                ]
            },
            // 按钮组
            drawer: false,
            direction: 'ttb',
            radio: '全部订单',
            radioList: ['全部订单', '待支付', '待确认', '待发货', '缺货', '已发货', '已签收', '已完成','已取消'],
            userId: '',
            dialogVisible1: false,
            dialogVisible2: false,
            dialogVisible3: false,
            ruleForm: {
                type: '',
                orderId: '',
                skuNo: '',
                money: '',
                reason: '',
                remarks: '',
                stockTotalPrice: 0,
            },
            statusOptions: [],
            options: [],
            brandOptions: [],
            optionProps: {
                value: 'id',
                label: 'name',
                children: 'children',
                multiple: false,
                emitPath: false
            },
            importAction: process.env.VUE_APP_BASE_API + '/secoo/poiImport', // 导服务器地址
            uploadImgUrl: process.env.VUE_APP_BASE_API + '/common/upload', // 上传的图片服务器地址
            headers: {
                Authorization: 'Bearer ' + getToken()
            },
            open: false,
            dealFile: [],
            datas: [],
            ishows: false,
            dialogVisibless: false,
            hiddens: false,
            msg: ''
        };
    },
    created() {
        console.log(localStorage);
        this.getList();
        this.getUrl('/web/getuserrole').then(response => {
            if (response.data.roleId == 101) {
                this.isshow = true;
            } else {
                this.cisshow = true;
            }
        });
        this.getDicts('plat_orderstatus').then(response => {
            this.statusOptions = response.data;
        });

        this.getUrl('/web/getCommonData').then(response => {
            this.options = this.getTreeData(response.data.catogery);
            this.brandOptions = response.data.brand;
        });
    },
    methods: {
        showbox() {
            this.dialogVisibless = false;
            this.hiddens = false;
        },
        handleQueryttt: function() {
            //  0 待支付 1已支付 2 待发货    3 缺货  4已发货  5 已签收  6 已完成  7 已退款'
            if (this.radio == '全部订单') {
                this.queryParams.status = '';
            } else if (this.radio == '待支付') {
                this.queryParams.status = 0;
            } else if (this.radio == '待确认') {
                this.queryParams.status = 1;
            } else if (this.radio == '待发货') {
                this.queryParams.status = 2;
            } else if (this.radio == '缺货') {
                this.queryParams.status = 3;
            } else if (this.radio == '已发货') {
                this.queryParams.status = 4;
            } else if (this.radio == '已签收') {
                this.queryParams.status = 5;
            } else if (this.radio == '已完成') {
                this.queryParams.status = 6;
            }else if (this.radio == '已取消') {
                this.queryParams.status = 9;
            }
            this.getList();
        },
        getTreeData(data) {
            for (var i = 0; i < data.length; i++) {
                if (data[i].children.length < 1) {
                    data[i].children = undefined;
                } else {
                    this.getTreeData(data[i].children);
                }
            }
            return data;
        },
        saveBtn: function(mark) {
            this.ruleForm.type = mark;
            if (this.ruleForm.money == '' || this.ruleForm.money == 0) {
                this.msgError('金额不能为空');
                return false;
            }

            var numReg = /^([1-9][\d]{0,7}|0)(\.[\d]{1,2})?$/;
            var numRe = new RegExp(numReg)
            if (!numRe.test(this.ruleForm.money)) {
                this.msgError("请输入正常格式的金额");
                return false;
            }

            if (this.ruleForm.money > this.ruleForm.stockTotalPrice) {
                this.msgError('售后金额不能超过结算金额:'+this.ruleForm.stockTotalPrice);
                return false;
            }
            if (this.ruleForm.reason == '') {
                this.msgError('原因不能为空');
                return false;
            }
            let datas = {
                type: this.ruleForm.type,
                orderId: this.ruleForm.orderId,
                skuNo: this.ruleForm.skuNo,
                money: this.ruleForm.money,
                reason: this.ruleForm.reason,
                remarks: this.ruleForm.remarks
            };
            btnshouhou(datas).then(response => {
                if (response.code === 200) {
                    this.msgSuccess('提交成功，等待后台审核，详情见售后订单列表页');
                    this.resetruleform();
                    this.open = false;
                    (this.dialogVisible1 = false), (this.dialogVisible2 = false), (this.dialogVisible3 = false), this.getList();
                } else {
                    this.msgError(response.msg);
                }
            });
        },
        //重置表单参数
        resetruleform() {
            this.ruleForm.type = '';
            this.ruleForm.money = '';
            this.ruleForm.reason = '';
            this.ruleForm.remarks = '';
        },
        //单个商品的退换货
        sopenkuang: function(mark, orderId, skuNo, row) {
            console.log(row)
            if (mark == 1) {
                this.dialogVisible1 = true;
            }
            if (mark == 2) {
                this.dialogVisible2 = true;
            }
            if (mark == 3) {
                this.dialogVisible3 = true;
            }
            this.ruleForm.orderId = orderId;
            this.ruleForm.skuNo = skuNo;
            this.ruleForm.stockTotalPrice = row.stockPrice;
        },
        //单个订单的退换货
        openkuang: function(mark, orderId, row) {
            console.log(row)
            if (mark == 1) {
                this.dialogVisible1 = true;
            }
            if (mark == 2) {
                this.dialogVisible2 = true;
            }
            if (mark == 3) {
                this.dialogVisible3 = true;
            }
            this.ruleForm.orderId = orderId;
            this.ruleForm.skuNo = '';
            this.ruleForm.stockTotalPrice = row.stockTotalPrice;
        },

        // 从详情返回
        toRetreat() {
            this.open = false;
        },
        /** 查询订单列表 */
        getList() {
            this.loading = true;
            setTimeout(() => {
                if (localStorage.userId == '4') {
                    listOrder(this.queryParams).then(response => {
                        this.orderList = response.rows;
                        this.orderList.forEach(item => {
                            item.peopleInfo = item.recipientsName + item.province + item.city + item.county + item.streetDetail;
                            // 0 待支付 1已支付 2 待发货    3 缺·货  4已发货  5 已签收  6 已完成  7 已退款
                            if (item.status == 0) {
                                item.status = '待支付';
                            } else if (item.status == 1) {
                                item.status = '待确认';
                            } else if (item.status == 2) {
                                item.status = '待发货';
                            } else if (item.status == 3) {
                                item.status = '缺货';
                            } else if (item.status == 4) {
                                item.status = '已发货';
                            } else if (item.status == 5) {
                                item.status = '已签收';
                            } else if (item.status == 6) {
                                item.status = '已完成';
                            } else if (item.status == 7) {
                                item.status = '已退款';
                            }
                        });
                        this.total = response.total;
                        this.loading = false;
                    });
                } else {
                    if (localStorage.nn) {
                        listOrder(this.queryParams).then(response => {
                            this.orderList = response.rows;
                            this.orderList.forEach(item => {
                                item.peopleInfo = item.recipientsName + item.province + item.city + item.county + item.streetDetail;
                                // 0 待支付 1已支付 2 待发货    3 缺·货  4已发货  5 已签收  6 已完成  7 已退款
                                if (item.status == 0) {
                                    item.status = '待支付';
                                } else if (item.status == 1) {
                                    item.status = '待确认';
                                } else if (item.status == 2) {
                                    item.status = '待发货';
                                } else if (item.status == 3) {
                                    item.status = '缺货';
                                } else if (item.status == 4) {
                                    item.status = '已发货';
                                } else if (item.status == 5) {
                                    item.status = '已签收';
                                } else if (item.status == 6) {
                                    item.status = '已完成';
                                } else if (item.status == 7) {
                                    item.status = '已退款';
                                }
                            });
                            this.total = response.total;
                            this.loading = false;
                        });
                    } else {
                        // this.$message.error('请添加店铺后，再次尝试。');
                    }
                }
            }, 50);
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.resetruleform();
            (this.dialogVisible1 = false), (this.dialogVisible2 = false), (this.dialogVisible3 = false), this.reset();
        },
        // 表单重置
        reset() {
            this.form = {
                id: undefined,
                uid: undefined,
                companyName: undefined,
                number: undefined,
                type: undefined,
                status: '0',
                platId: undefined,
                plat: undefined,
                shopId: undefined,
                shop: undefined,
                platOrderid: undefined,
                orderTime: undefined,
                payTime: undefined,
                payPrice: undefined,
                prePrice: undefined,
                extension: undefined,
                createdTime: undefined
            };
            this.resetForm('form');
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;

            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm('queryForm');
            this.handleQuery();
            this.queryParams.orderTime = '';
            this.queryParams.contactWay = '';
            this.queryParams.companyName = '';
            this.queryParams.brandNo = '';
            this.queryParams.orderId = '';
            this.queryParams.orderIda = '';
            this.queryParams.categoryNo = '';
            this.queryParams.skuNo = '';
            this.queryParams.goodsNo = '';
            this.queryParams.shop = '';
            this.queryParams.plat = '';
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.id);
            this.single = selection.length != 1;
            this.multiple = !selection.length;
            this.queryParams.orderIdList = this.ids.join(',');
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.reset();
            this.open = true;
            this.title = '添加订单';
        },
        /** 修改按钮操作 */
        handleUpdate(row) {
            this.open = true;
            this.reset();
            const id = row.id || this.ids;
            //getOrder(id).then(response => {
            //    this.form = response.data;
                this.form = row;
                this.open = true;
                this.title = '修改订单';
            //});
        },
        /** 提交按钮 */
        submitForm: function() {
            this.$refs['form'].validate(valid => {
                if (valid) {
                    if (this.form.id != undefined) {
                        updateOrder(this.form).then(response => {
                            if (response.code === 200) {
                                this.msgSuccess('修改成功');
                                this.open = false;
                                this.getList();
                            } else {
                                this.msgError(response.msg);
                            }
                        });
                    } else {
                        addOrder(this.form).then(response => {
                            if (response.code === 200) {
                                this.msgSuccess('新增成功');
                                this.open = false;
                                this.getList();
                            } else {
                                this.msgError(response.msg);
                            }
                        });
                    }
                }
            });
        },
        /** 删除按钮操作 */
        handleDelete(row) {
            const ids = row.id || this.ids;
            this.$confirm('是否确认删除订单编号为"' + ids + '"的数据项?', '警告', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            })
                .then(function() {
                    return delOrder(ids);
                })
                .then(() => {
                    this.getList();
                    this.msgSuccess('删除成功');
                })
                .catch(function() {});
        },
        /** 导出按钮操作 */
        handleExport() {
            const queryParams = this.queryParams;

            this.$confirm('是否确认导出订单数据项?', '警告', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            })
                .then(function() {
                    return exportOrder(queryParams);
                })
                .then(response => {
                    //this.download(response.msg);
                    this.msgSuccess(response.msg);
                })
                .catch(function() {});
        },
        handleImport() {},
        handl() {},
        //文件上傳
        fieldBeforeUpload(response, file) {
            this.dialogVisibless = true;
            if (response.code == 200) {
                this.lists = [];
                response.data.forEach(element => {
                    console.log(element);
                    console.log(element.errorFields);
                    this.lists.push(element.errorFields);
                });
                this.hiddens = false;
                this.datas = response.data;
            } else {
                this.hiddens = true;
                this.msg = response.msg;
            }
            this.dealFile = [];
        },
        update() {
            if (window.navigator.msSaveBlob) {
                // IE以及IE内核的浏览器
                try {
                    window.navigator.msSaveBlob(res, fileName); // res为接口返回数据，这里请求的时候已经处理了，如果没处理需要在此之前自行处理var data = new Blob([res.data]) 注意这里需要是数组形式的,fileName就是下载之后的文件名
                    // window.navigator.msSaveOrOpenBlob(res, fileName);  //此方法类似上面的方法，区别可自行百度
                } catch (e) {
                    console.log(e);
                }
            } else {
                let link = document.createElement('a');
                link.href = process.env.VUE_APP_BASE_API + '/secoo/exportOrderTemplate';
                // let url = window.URL.createObjectURL(new Blob([res]))
                link.style.display = 'none';
                document.body.appendChild(link);
                link.click();
                document.body.removeChild(link); // 下载完成移除元素
                window.URL.revokeObjectURL(url); // 释放掉blob对象
            }
            // update().then(res => {
            //     console.log(res);
            // });
        },
        fileBeforeUpload(file) {
            let isRightSize = file.size / 1024 / 1024 < 2;
            if (!isRightSize) {
                this.$message.error('上传文件不能大于2MB');
                return false;
            }
            console.log(file);
            if (file.type != 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' && file.type != 'application/vnd.ms-excel') {
                this.$message.error('只能上传.xls,.xlsx文件');
                return false;
            }
        }
    },
    watch: {
        '$store.state.user.shopid': function(newFlag, oldFlag) {
            // 需要执行的代码
            this.queryParams.shopId = this.$store.state.user.shopid;
            this.getList();
        }
    }
};
</script>
<style rel="stylesheet/scss" lang="scss">
.salesTypes input {
    width: 255px;
}
.order .tableCont {
    display: flex;
}
.order .tableCont img {
    width: 60px;
    height: 60px;
    float: left;
}
.order .tableCont div:nth-child(2) {
    float: left;
    flex: 1;
    margin-left: 20px;
}
.order .sync {
    width: 100%;
    display: flex;
    margin-top: 20px;
}
.order .sync > span {
    flex: 1;
    text-align: right;
}
.order .sync .input {
    width: 78%;
    margin-left: 10px;
}
.order .elbutton {
    display: block;
    height: 20px;
    padding: 0;
}
.order .el-table .cell > div {
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: break-all;
    line-height: 23px;
    padding-left: 10px;
    padding-right: 10px;
}
.order .el-table .cell > div {
    columns: #2777da !important;
}
.order .el-upload-list {
    display: none !important;
}
</style>
